
#include "Astronomy/JDateTime.hpp"
#include "Config/Config.hpp"

#include "Astronomy/Celestial/Moon.hpp"
#include "Astronomy/Celestial/Sun.hpp"
#include "Astronomy/Constant.hpp"
#include "Astronomy/RiseTransitSet.hpp"
#include "Astronomy/SolarTerms.hpp"
#include "SexagenaryCycle.hpp"


#include <cstdio>
#include <iostream>
#include <ostream>

void printVersion()
{
    std::cout << "[>>>>>-  App Info  -<<<<<<]" << std::endl;
    std::cout << "\t-> AppVersion: " << APP_FULL_VERSION_STRING << std::endl;
    std::cout << "\t-> Build Time: " << APP_BUILD_TIME << std::endl;
    std::cout << "\t-> Git Branch: " << APP_GIT_BRANCH_NAME << std::endl;
    std::cout << "\t-> Git Commit: " << APP_GIT_COMMIT_HASH << std::endl << std::endl;;

    std::cout << "[>>>>>- App Message -<<<<<<]" << std::endl;
}
int main()
{
    printVersion();

    JDateTime date{-245};
    // Sun;
    auto longitude = CelestialSun::ApparentEclipticLocation(0.008582968944889204, false); //= 55.66789716926433;
    std::cout << "[CelestialSun::ApparentEclipticLocation(0.008582968944889204, false)]\n\t-> JDateTime :" << date.ToString() << std::endl;
    std::cout << "\t-> EclipticLongitude :" << longitude.X << "\n\t-> EclipticLatitude :" << longitude.Y << std::endl;

    // Moon;
    auto [mint, minr] = CelestialMoon::CalcApogeeOrPerigee(-0.000013689253935660506);
    std::cout << "[CalcApogeeOrPerigee](-0.000013689253935660506)" << "\n\t-> minMoon T :" << mint << "\t-> R :" << minr << " km" << std::endl;

    // RiseTransitSet;
    RiseTransitSet rts(2.0312723552949694, 0.6963863715457375);
    auto           tt = rts.St(2921.676712963889);
    std::cout << "\n[RiseTransitSet::St(2921.676712963889)]" << std::endl;

    std::cout << "\t->  Sun Rise:" << JDateTime::ToTimeString(tt.Rise + Constants::J2000 + 8.0 / 24.0);
    std::cout << "\t->  Sun  Set:" << JDateTime::ToTimeString(tt.Set + Constants::J2000 + 8.0 / 24.0) << std::endl;
    std::cout << "\t->  Sunlight:" << JDateTime::ToTimeString(tt.GetSunlight());
    std::cout << "\t-> DayLength:" << JDateTime::ToTimeString(tt.GetDayLength()) << std::endl;

    tt = rts.Mt(2921.676712963889);
    std::cout << "[RiseTransitSet::Mt(2921.676712963889)]" << "\n\t-> moon rise  :" << JDateTime::ToTimeString(tt.Rise)
              << "\t-> moon set :" << JDateTime::ToTimeString(tt.Set) << std::endl;


    // SolarTerms;
    SolarTerms solarTerm;
    solarTerm.CalcYear(8038);
    auto jtime = SolarTerms::CalcSuoAccurateOnJulianDate(8038);
    printf("\n[SolarTerms::CalcSuoAccurateOnJulianDate(8038)]\n \t-> JDateTime:%f\n \t-> %f( %s )\n",
           8903.0 + Constants::J2000,
           jtime,
           JDateTime::ToString(jtime + Constants::J2000).c_str());

    // SexagenaryCycleDate;
    SexagenaryCycleDate sc(8925.668182870373, 2.0312723552949694);
    date.setJulianDateTime(8925.668182870373 + Constants::J2000);
    JDateTime time(sc.apparentSolarTimeJd);
    printf("\n[SexagenaryCycleDate(8925.668182870373,2.0312723552949694)]\n\t-> DateTime:%s,\n\t-> %s\n\t-> %s\n",
           date.ToString().c_str(),
           time.ToTimeString().c_str(),
           sc.ToString().c_str());

    //;
    return 0;
}